﻿USE [Twitter]
GO
/****** Object:  Table [dbo].[Status]    Script Date: 04/17/2011 23:33:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Status](
	[id_status] [int] NOT NULL,
	[status] [varchar](50) NULL,
 CONSTRAINT [PK_Status] PRIMARY KEY CLUSTERED 
(
	[id_status] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Messages]    Script Date: 04/17/2011 23:33:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Messages](
	[id_message] [int] NOT NULL,
	[message] [varchar](140) NOT NULL,
	[id_user] [int] NOT NULL,
	[id_for_user] [int] NOT NULL,
	[date_time] [timestamp] NOT NULL,
 CONSTRAINT [PK_Messages] PRIMARY KEY CLUSTERED 
(
	[id_message] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Follows]    Script Date: 04/17/2011 23:33:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Follows](
	[id_follows] [int] NOT NULL,
	[id_user] [int] NOT NULL,
	[id_user_follow] [int] NOT NULL,
 CONSTRAINT [PK_Follows] PRIMARY KEY CLUSTERED 
(
	[id_follows] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Passwords]    Script Date: 04/17/2011 23:33:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Passwords](
	[id_password] [int] NOT NULL,
	[id_user] [int] NOT NULL,
	[password] [varchar](50) NOT NULL,
 CONSTRAINT [PK_Passwords] PRIMARY KEY CLUSTERED 
(
	[id_user] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Users]    Script Date: 04/17/2011 23:33:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Users](
	[id_users] [int] NOT NULL,
	[nick] [varchar](20) NOT NULL,
	[name] [varchar](20) NOT NULL,
	[lastname] [varchar](20) NULL,
	[middlename] [varchar](20) NULL,
	[id_status] [int] NOT NULL,
 CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED 
(
	[id_users] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  ForeignKey [FK_Follows_Users]    Script Date: 04/17/2011 23:33:50 ******/
ALTER TABLE [dbo].[Follows]  WITH NOCHECK ADD  CONSTRAINT [FK_Follows_Users] FOREIGN KEY([id_user])
REFERENCES [dbo].[Users] ([id_users])
GO
ALTER TABLE [dbo].[Follows] CHECK CONSTRAINT [FK_Follows_Users]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'FK_Follows_Users' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Follows', @level2type=N'CONSTRAINT',@level2name=N'FK_Follows_Users'
GO
/****** Object:  ForeignKey [FK_Messages_Users]    Script Date: 04/17/2011 23:33:50 ******/
ALTER TABLE [dbo].[Messages]  WITH CHECK ADD  CONSTRAINT [FK_Messages_Users] FOREIGN KEY([id_user])
REFERENCES [dbo].[Users] ([id_users])
GO
ALTER TABLE [dbo].[Messages] CHECK CONSTRAINT [FK_Messages_Users]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'FK_Messages_Users' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Messages', @level2type=N'CONSTRAINT',@level2name=N'FK_Messages_Users'
GO
/****** Object:  ForeignKey [FK_Passwords_Users]    Script Date: 04/17/2011 23:33:50 ******/
ALTER TABLE [dbo].[Passwords]  WITH CHECK ADD  CONSTRAINT [FK_Passwords_Users] FOREIGN KEY([id_user])
REFERENCES [dbo].[Users] ([id_users])
GO
ALTER TABLE [dbo].[Passwords] CHECK CONSTRAINT [FK_Passwords_Users]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'FK_Users_Passwords' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Passwords', @level2type=N'CONSTRAINT',@level2name=N'FK_Passwords_Users'
GO
/****** Object:  ForeignKey [FK_Users_Status]    Script Date: 04/17/2011 23:33:50 ******/
ALTER TABLE [dbo].[Users]  WITH CHECK ADD  CONSTRAINT [FK_Users_Status] FOREIGN KEY([id_status])
REFERENCES [dbo].[Status] ([id_status])
GO
ALTER TABLE [dbo].[Users] CHECK CONSTRAINT [FK_Users_Status]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Relation described status of twitter user' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'CONSTRAINT',@level2name=N'FK_Users_Status'
GO